<?php

class Sistema_Form_Pacote extends Zend_Form
{

    public function init()
    {
        $front = Zend_Controller_Front::getInstance();
        $controller = $front->getRequest()->getControllerName();
        $module = $front->getRequest()->getModuleName();
        $url = $front->getBaseUrl().'/'.$module.'/'.$controller;
        
        $this->setName('form_'.$controller);
        
        $el = new Zend_Form_Element_Hidden('PCT_ID',array('disableLoadDefaultDecorators' =>true));
        $el->addDecorators(array(array('ViewHelper'),array('Errors')))->addFilter('Int');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PCT_NOM');
        $el->setLabel('Nome')->setRequired(true)
        ->addFilters(array('StripTags','StringTrim'))->addValidator('NotEmpty');
        $el->setAttrib('required','');
        $el->setAttrib('maxlength','32');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Textarea('PCT_TXT');
        $el->setLabel('Texto')->setRequired(true)
        ->addFilters(array('StripTags','StringTrim'))->addValidator('NotEmpty');
        $el->setAttrib('required','');
        $el->setAttrib('style','width: 170px !important; height: 85px; text-align: justify;');
        //$el->setAttrib('maxlength','130');
        $this->addElement($el);
        
        
        $el = new Zend_Form_Element_Text('PCT_VAL');
        $el->setLabel('Valor')->setRequired(false)
        ->addFilters(array('StripTags','StringTrim'))->addValidator('NotEmpty');
        //$el->setAttrib('required','');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PCT_VALPRO');
        $el->setLabel('Promoção')->setRequired(false)
        ->addFilters(array('StripTags','StringTrim'))->addValidator('NotEmpty');
        //$el->setAttrib('required','');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PCT_VALTXT');
        $el->setLabel('Descrição do valor');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PCT_DATPRO');
        $el->setLabel('Validade da Promoção')->setRequired(false)
        ->addFilters(array('StripTags','StringTrim'))->addValidator('NotEmpty');
        //$el->setAttrib('required','');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Checkbox('PCT_STADATPRO',array());
        $el->setLabel('Mostrar Validade da Promoção');
        $this->addElement($el);
        
        $img = 'public/upload/'.$controller.'/'.$front->getRequest()->getParam('id').'.*';
        foreach (glob($img) as $src) {
            $el = new Zend_Form_Element('img',array( 'helper'=>'formNote', 'value'=>'<img src="'.$front->getBaseUrl().'/'.$src.'" />' ));
            $this->addElement($el);
        }
        $el = new Zend_Form_Element_File('PCT_FILE');
        $el->setLabel('Imagem - Tamanho: 221x160')
	->addValidator('Extension', false, array('jpg', 'png', 'gif'));
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Text('PCT_ORD');
        $el->setLabel('Ordem')
        ->setRequired(true)
        ->addFilter('Int')
        ->addValidator('NotEmpty');
        $this->addElement($el);
        
        $el = new Zend_Form_Element_Checkbox('PCT_STA',array('checked'=>'checked'));
        $el->setLabel('Status');
        $this->addElement($el);
        
        $btn = new Zend_Form_Element_Submit('Salvar',array('disableLoadDefaultDecorators' =>true));
        $btn->addDecorators(array(array('ViewHelper'),array('Errors')));
        $btn->setLabel('Salvar');
        $btn->setAttrib('id', 'submitbutton');
        $btn->setAttrib('class', 'btn-frm');
        $this->addElement($btn);
        
        $btn = new Zend_Form_Element_Button('Cancelar',array('disableLoadDefaultDecorators' =>true));
        $btn->setDecorators(array(array('Description', array('escape' => false, 'tag' => false))));
        $btn->setDescription('<a href="'.$url.'" class="btn-frm">Voltar</a>');
        $btn->setAttrib('id', 'btncancel');
        $btn->setAttrib('class', 'btn-frm');
        $this->addElement($btn);
    }


}

